package cn.rkylin.oms.base.refundReasonType.utils.apprhandler.impl;

import cn.rkylin.oms.aftersale.sysrefund.vo.SysRefundVO;
import cn.rkylin.oms.aftersale.sysreturn.vo.SysReturnVO;
import cn.rkylin.oms.base.refundReasonType.utils.apprhandler.ApprHandler;
import cn.rkylin.oms.common.consts.YesNoConst;

import java.util.List;

public class HasReturnHandler extends ApprHandler {
    private String ruleContent = "本条退款无需退货，但系统中存在已退入的退货单";

    /**
     * getRuleContent:获取规则内容. <br/>
     *
     * @return
     * @author zhanghao
     */
    @Override
    protected String getRuleContent() {
        return ruleContent;
    }

    /**
     * isValid:检查校验是否通过. <br/>
     *
     * @param sysRefundVO
     * @return
     * @author zhanghao
     */
    @Override
    protected boolean isValid(SysRefundVO sysRefundVO) throws Exception {
        boolean returnValue = true;
        if (YesNoConst.NO.equalsIgnoreCase(sysRefundVO.getHasGoodReturn())) {
            List<SysReturnVO> sysReturnVOList = sysRefundVO.getSysReturnVOList();
            for (SysReturnVO sysReturnVO : sysReturnVOList) {
                if ("z".equals(sysReturnVO.getReturnStatus())) {
                    returnValue = false;
                    break;
                }
            }
        }
        return returnValue;
    }

    /**
     * getRuleCheckArray:获取条件校验数组. <br/>
     *
     * @return
     * @author zhanghao
     */
    @Override
    protected int[] getRuleCheckArray() {
        return new int[0];
    }

    /**
     * getRuleLevel:获取校验规则的级别. <br/>
     *
     * @author zhanghao
     * @return
     */
    @Override
    protected String getRuleLevel() {
        String returnResult = MSG_CONFIRM; // 本条规则总是confirm
        return returnResult;
    }
}
